<!DOCTYPE html>
<html>
<head>
    <link rel="stylesheet" href="../../lib/layui/css/layui.css">
    <link rel="stylesheet" href="../../css/oksub.css">
    <meta charset="utf-8">
    <title>待分配警情列表页</title>
</head>
<style>
    .list-con {
        padding: 0 10px 15px 10px;
        margin-bottom: 20px;
    }

    .list-con .layui-table td,
    .layui-table-view,
    .layui-table[lay-skin=line],
    .layui-table[lay-skin=row] {
        border: none;
    }

    .list-con .layui-table tbody {
        color: #777777;
    }

    .list-con .layui-table tbody tr:hover,
    .layui-table[lay-even] tr:nth-child(even) {
        background-color: rgb(226, 226, 226);
        color: black;
        font-weight: bold;
    }

    .layui-table tr {
        border-bottom: 1px #e2e2e2 solid;
    }

</style>

<body>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
    <legend>待分派警情</legend>
</fieldset>

<!--数据表格-->
<div class="list-con">
    <table class="layui-hide" id="tableId" lay-filter="tableId"></table>
</div>
</body>
<script src="../../lib/layui/layui.js"></script>
<script src="../../js/jquery.min.js"></script>
<script src="../../js/application.js"></script>
<script src="../../js/model.js"></script>
<script>
    layui.use(["table", "laydate", "okLayer", "okNprogress"], function () {
        let $ = layui.jquery;
        let table = layui.table;
        let form = layui.form;
        let laydate = layui.laydate;
        let okLayer = layui.okLayer;
        let okNprogress = layui.okNprogress;
        //警情导入详细列表信息页
        let articleTable = table.render({
            elem: "#tableId",
            url: mainUri + "/case/getPendingCases",
            where: {
                'selectConditionJson':JSON.stringify( new SelectCondition("","","","","",false))
            },
            toolbar: true,
            toolbar: "#toolbarTpl",
            cols: [[
                {field: "caseId", title: "警情编号", width: 150},
                {field: "reportingContent", title: "报警内容"},
                {
                    field: "reportingLevel", title: "警情级别", width: 100, templet: function (d) {
                        if (d.reportingLevel == "一级警情") {
                            return "<div style='color:#d92d29;font-weight: bold;font-size:15px'>" + d.reportingLevel + "</div>"
                        } else if (d.reportingLevel == "二级警情") {
                            return "<div style='color:#f09614;font-weight: bold;font-size:15px'>" + d.reportingLevel + "</div>"
                        } else if (d.reportingLevel == "三级警情") {
                            return "<div style='color:#fae600;font-weight: bold;font-size:15px'>" + d.reportingLevel + "</div>"
                        } else{
                            return "<div style='color:#478f43;font-weight: bold;font-size:15px'>" + d.reportingLevel + "</div>"
                        }
                    }
                },
                {field: "alarmCategory", title: "报警类别", width: 150,templet: function (d) {
                    return d.alarmCategory+"-"+d.alarmType+"-"+d.alarmSystem+"-"+d.alarmSubclass
                    }},
                {field: "incidentSite", title: "事发地址", width: 250},
                {field: "reportingTime", title: "报警时间", width: 200}
            ]],
            page: {
                layout: ['prev', 'page', 'next', 'skip', 'count'],
                groups: 3,
                limit: 15,
                theme: '#1E9FFF',
            }
        });

        //监听行单击事件
        table.on('row(tableId)', function (obj) {
            var data = obj.data;
            let uri = "pendingCase.html?caseId=" + data.caseId;
            uri+="&reportingContent="+data.reportingContent
            show(uri);
            //标注选中样式
            obj.tr.addClass('layui-table-click').siblings().removeClass('layui-table-click');
        });

        function show(uri) {
            window.open(uri, 'newwindow', 'width=' + (window.screen.availWidth - 10) + ',height=' + (window.screen.availHeight - 30) + ', top=0, left=0, toolbar=no, menubar=no, scrollbars=yes, resizable=yes,location=no, status=no')
        }


        table.on("toolbar(tableId)", function (obj) {
            switch (obj.event) {
                case "excelImport"://警情导入
                    excelImport();
                    break;
                case "selectForm"://搜索
                    selectForm();
                    break;
                case "backAll"://刷新
                    backAll();
                    break;
            }
        });
        //警情导入显示
        function excelImport() {
            okLayer.open("警情导入", "caseImport.html", "90%", "90%", null, function () {
                // 开始进度条
                okNprogress.start();
                //重载表格
                articleTable.reload();
                // 结束进度条
                okNprogress.done();
            });
        }

        //根据条件获取数据
		function selectForm() {
			okLayer.open("查询条件", "selectFormPending.html", "35%", "60%", function (layero) {
				let iframeWin = window[layero.find("iframe")[0]["name"]];
			}, function () {
				//根据子页面传过来的查询参数进行查询
				var caseId = window.document.caseId;
				var procLevel = window.document.procLevel;
				var caseDescription = window.document.caseDescription;
				var startTime = window.document.startTime;
				var endTime = window.document.endTime;
                var newStartDate = startTime.replace(/-/g,"/");
                var newEndDate = endTime.replace(/-/g,"/");
                //将搜索框置空
                window.document.caseId="";
                window.document.procLevel="";
                window.document.caseDescription="";
                window.document.startTime="";
                window.document.endTime="";
                var isChange=window.document.isChange;
                window.document.isChange=0
                if(isChange!=1){
                    return
                }
				articleTable.reload({
                    method: 'post',
					where: {
                        'selectConditionJson':JSON.stringify( new SelectCondition(caseId,procLevel,caseDescription,newStartDate,newEndDate,false))
					},
                    page: {curr: 1}
				})
			})
		}

		//获取全部数据  刷新
		function backAll(){
			articleTable.reload({
                method: 'post',
                where: {
                    'selectConditionJson':JSON.stringify( new SelectCondition("","","","","",false))
                },
                page: {curr: 1}
			})
		}
    })
</script>
<!-- 头工具栏模板 -->
<script type="text/html" id="toolbarTpl">
    <div class="layui-btn-container">
        <button type="button" class="layui-btn layui-btn-normal layui-btn-radius" lay-event="excelImport">选择Excel文件
        </button>
		<button type="button" class="layui-btn layui-btn-normal layui-btn-radius" lay-event="backAll">全部数据
		</button>
		<button type="button" class="layui-btn layui-btn-normal layui-btn-radius" lay-event="selectForm"> <i class="layui-icon layui-icon-search"></i>
		</button>
    </div>
</script>
</html>